home *** CD-ROM | disk | FTP | other *** search
/ Total Network Tools 2002 / NextStepPublishing-TotalNetworkTools2002-Win95.iso / Archive / Misc Servers / Zope.exe / GFINSTALL.PY < prev    next >
Encoding:
Python Source  |  1999-07-28  |  1.5 KB  |  68 lines

  1. #!/usr/local/bin/python
  2.  
  3. """Gadfly installation script.
  4.  
  5. Build the sql grammar.
  6.  
  7. usage
  8.   python <thismodule>
  9. for a simple install or
  10.   python <thismodule> force
  11. for a full rebuild (with grammar regeneration).
  12.  
  13. In the current directory find or create sql.mar and sqlwhere.py
  14. where sql.mar has the marshalled grammar data structures
  15. for parsing sql and sqlwhere.py is a module that indicates
  16. where the grammar file is as value of sqlwhere.filename.
  17. """
  18.  
  19. marfile = "sql.mar"
  20. modfile = "sqlwhere.py"
  21.  
  22. print __doc__
  23.  
  24. from os import getcwd, path
  25. cwd = getcwd()
  26.  
  27. modtemplate ="""
  28. '''this module indicates where the sql datastructures are marshalled
  29.    Auto generated on install: better not touch!
  30. '''
  31.  
  32. filename = %s
  33. """
  34.  
  35. #wheremod = cwd + "/" + modfile
  36. #where = cwd + "/" + marfile
  37. wheremod = path.join(cwd, modfile)
  38. where = path.join(cwd, marfile)
  39. print
  40. print "now creating", wheremod
  41. f = open(wheremod, "w")
  42. f.write( modtemplate % (`where`,) )
  43. f.close()
  44.  
  45. from sqlgen import BuildSQL, getSQL
  46. import sys
  47. argv = sys.argv
  48. force = 0
  49. #print argv
  50. if len(argv)>1 and argv[1]=="force":
  51.    force = 1
  52. if not force:
  53.    try:
  54.        sql = getSQL()
  55.    except:
  56.        print "exception", sys.exc_type, sys.exc_value
  57.        print "during load of SQL grammar structures."
  58.        print "Apparently the SQL grammar requires regeneration"
  59.        force = 1
  60. if force:
  61.    print "now generating parser structures (this might take a while)..."
  62.    #where = cwd + "/" + marfile
  63.    print "building in", where
  64.    sql = BuildSQL(where)
  65. print
  66. print "done."
  67.  
  68.